package indi.yudidi.ioc.how2java.test;

import indi.yudidi.ioc.how2java.annotation.MyAutowired;
import indi.yudidi.ioc.how2java.pojo.BaseInject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class InheritAutowired extends BaseInject {

    @Autowired(required = true)
    @MyAutowired
    private String paramString;

    @Test
    public void myAutowiredTest() {
        InheritAutowired inheritAutowired = new InheritAutowired();
        assertEquals("hello world", inheritAutowired.paramString);
    }

    @Test
    public  void  resource() throws IOException {
        // 定义一个枚举的集合 并进行循环来处理这个目录下的things
        Enumeration<URL> dirs;                                  //定义一个枚举类型的集合  类URL 代表一个统一资源定位符，它是指向互联网“资源”的指针
        dirs = Thread.currentThread().getContextClassLoader().getResources("indi/yudidi/ioc/test.txt");     //得到指定类加载器下面的资源
        while (dirs.hasMoreElements()){
            // 获取下一个元素
            URL url = dirs.nextElement();
            System.out.println(url.getPath());
        }
    }

}